home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
dt01
/
dt01.bas
< prev
next >
Wrap
BASIC Source File
|
1995-05-09
|
2KB
|
56 lines
' ---------------------------------------------
' I don't like globals any more than you.
' The alternatives are not so brilliant either.
' ---------------------------------------------
Global gDate
Type POINTAPI
x As Integer
y As Integer
End Type
' Converts the client coordinates of a given point on the screen to screen coordinates.
Declare Sub ClientToScreen Lib "User" (ByVal hWnd As Integer, lpPoint As POINTAPI)
Sub calendar (cbo As ComboBox)
Dim lp As POINTAPI
' Set global date, so (.frm) level can see it.
gDate = cbo.Text
' -----------------------------------------------------------------
' My plan is to position the calendar display directly under
' the 'Combo Box'. (good plan). We can get the 'combo bottom'
' co-ordinate simply by taking the form top (combo's parent top)
' and adding the combo's top & combo's height.
' A problem occurs however, if the combo is 'inside' another
' control, ie: a frame control. We need then to add that control's
' top property to get the correct co-ordinate. What if that frame
' is within another frame? and so on... All we want basically,
' is the absolute screen location of the combo box, and not it's
' "relativitiness" within other controls.
' The API function "ClientToScreen" will give us the absolute
' screen location of a control. Converting the result from pixels
' into twips gives the point we want.
' ------------------------------------------------------------------
lp.x = 0
lp.y = 0
ClientToScreen cbo.hWnd, lp
' Position calendar underneath ComboBox
frmCalendar.Top = lp.y * screen.TwipsPerPixelY + cbo.Height
frmCalendar.Left = lp.x * screen.TwipsPerPixelX
frmCalendar.Show 1
cbo.Text = Format$(gDate, "dd-mmm-yyyy")
cbo.SetFocus
SendKeys "%{UP}"
End Sub